
# MMDS Server Console v0.1


# Adding Student Information to MMDS Database


import sys

import os

import MySQLdb

try:
	
	db = MySQLdb.Connect(host="127.0.0.1", port=3306, user="root", passwd="",db="mmds")


except MySQLdb.Error, e:
 
	print "\n\n*****************************************\n"
     
	print "MMDS Error %d: %s" % (e.args[0], e.args[1])
     
	print "\n\n*****************************************\n"
	
	sys.exit (1)
     
cursor = db.cursor()

print "\nWelcome to MMDS Server Console v0.1"

print "\nEnter the Student Details :\n"

userid = raw_input("\n\tLogin ID\t:\t" )

studname = raw_input("\n\tStudent Name\t:\t")

stud_pass = raw_input("\n\tPassword\t:\t")

class_st = raw_input("\n\tClass\t\t:\t")

course_name = raw_input("\n\tCourse Name\t:\t")

course_code = raw_input("\n\tCourse Code\t:\t")

lab_sess = raw_input("\n\tLab Session\t:\t")

sys_no = raw_input("\n\tSystem No\t:\t")

doe = raw_input("\n\tData of Exam\t:\t")


sql = 'Insert into mmds_userinfo values( "%i","%s", "%s", "%s", "%s", "%s", "%s", "%i", "%s")' % (int(userid),studname,stud_pass,class_st,course_name,course_code,lab_sess, int(sys_no) ,doe) 

#cursor.execute('Insert into mmds_userinfo values( "%i","%s", "%s", "%s", "%s", "%s", "%s", "%i", "%s")' % (int(userid),studname,stud_pass,class_st,course_name,course_code,lab_sess, int(sys_no) ,doe) )

cursor.execute(sql)


print "\n\nStudent Informations are Added Successfully!... \n\n"


db.close()
